package com.yuchen.ishop.web.app;

import com.yuchen.core.MyPager;
import com.yuchen.ishop.service.goods.GoodsRestClient;
import com.yuchen.ishop.web.BaseAction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * 2级导购
 */
@Controller
public class GoodsGuideAction extends BaseAction {

    @Autowired
    private GoodsRestClient goodsRestClient;

    @RequestMapping(value = {"guide"})
    public String guide(String keywords,ModelMap modelMap, HttpServletRequest request) {
        modelMap.addAttribute("myNav","guide");
        Map params = convertParameterMap(request.getParameterMap());
        if(params==null) params = new HashMap();
        params.put("keywords",keywords);
        MyPager myPager = goodsRestClient.finds(params);
        modelMap.addAttribute("pager",myPager);
        return "guide";
    }
}
